package com.ruoyi.web.controller.zhhq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zhhq.domain.ZhhqCanteecate;
import com.ruoyi.zhhq.service.IZhhqCanteecateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐厅分类Controller
 * 
 * @author ZLC
 * @date 2022-11-02
 */
@RestController
@RequestMapping("/zhhq/canteecate")
public class ZhhqCanteecateController extends BaseController
{
    @Autowired
    private IZhhqCanteecateService zhhqCanteecateService;

    /**
     * 查询餐厅分类列表
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZhhqCanteecate zhhqCanteecate)
    {
        startPage();
        List<ZhhqCanteecate> list = zhhqCanteecateService.selectZhhqCanteecateList(zhhqCanteecate);
        return getDataTable(list);
    }
    
    /**
     * 查询餐厅分类列表
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:list')")
    @GetMapping("/listAll")
    public TableDataInfo listAll()
    {
        List<ZhhqCanteecate> list = zhhqCanteecateService.selectZhhqCanteecateListAll();
        return getDataTable(list);
    }
    

    /**
     * 导出餐厅分类列表
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:export')")
    @Log(title = "餐厅分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZhhqCanteecate zhhqCanteecate)
    {
        List<ZhhqCanteecate> list = zhhqCanteecateService.selectZhhqCanteecateList(zhhqCanteecate);
        ExcelUtil<ZhhqCanteecate> util = new ExcelUtil<ZhhqCanteecate>(ZhhqCanteecate.class);
        util.exportExcel(response, list, "餐厅分类数据");
    }

    /**
     * 获取餐厅分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:query')")
    @GetMapping(value = "/{rcateId}")
    public AjaxResult getInfo(@PathVariable("rcateId") String rcateId)
    {
        return AjaxResult.success(zhhqCanteecateService.selectZhhqCanteecateByRcateId(rcateId));
    }

    /**
     * 新增餐厅分类
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:add')")
    @Log(title = "餐厅分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZhhqCanteecate zhhqCanteecate)
    {
        return toAjax(zhhqCanteecateService.insertZhhqCanteecate(zhhqCanteecate));
    }

    /**
     * 修改餐厅分类
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:edit')")
    @Log(title = "餐厅分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZhhqCanteecate zhhqCanteecate)
    {
        return toAjax(zhhqCanteecateService.updateZhhqCanteecate(zhhqCanteecate));
    }

    /**
     * 删除餐厅分类
     */
    @PreAuthorize("@ss.hasPermi('zhhq:canteecate:remove')")
    @Log(title = "餐厅分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rcateIds}")
    public AjaxResult remove(@PathVariable String[] rcateIds)
    {
        return toAjax(zhhqCanteecateService.deleteZhhqCanteecateByRcateIds(rcateIds));
    }
}
